package com.hireceivecard.pojo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

/**
 * @Description: 统一返回实体类
 * @Author 2742866928@qq.com
 * @Date: 2024/3/24 0:15
 */
@ApiModel("统一返回实体类")
@Data
public class Result<T> implements Serializable {
    @ApiModelProperty("返回信息")
    private String message;
    @ApiModelProperty("返回实体")
    private T data;
    @ApiModelProperty("返回码")
    private int code;
    public Result(String message, T data, int code) {
        this.message = message;
        this.data = data;
        this.code = code;
    }
    public Result(String message, T data) {
        this.message = message;
        this.data = data;
    }
    public Result() {
    }

    /*
     * 新增一些返回方法
     * @param msg 返回字符串
     * @param data 返回具体数据
     */
    public static Result success(String msg) {
        return new Result(msg, null, 200);
    }

    public static <T> Result<T> success(T data, String msg) {
        return new Result<T>(msg, data, 200);
    }

    public static Result fail(String msg, int code) {
        return new Result(msg, code);
    }




}
